package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicSkReturnDAO;
import com.cssy.yd.logic.entity.LogicSkReturnDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-08-21
 */
public class LogicSkReturnDAOImpl extends SqlMapClientDaoSupport implements LogicSkReturnDAO {

    /**
     * 插入数据
     * @param logicSkReturnDO
     * @return 插入数据的主键
     */
    public String insertLogicSkReturnDO(LogicSkReturnDO logicSkReturnDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicSkReturn.insert", logicSkReturnDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicSkReturnDO
     * @return 查出的记录数
     */
    public Integer countLogicSkReturnDOByExample(LogicSkReturnDO logicSkReturnDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicSkReturn.countByDOExample", logicSkReturnDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicSkReturnDO
     * @return 受影响的行数
     */
    public Integer updateLogicSkReturnDO(LogicSkReturnDO logicSkReturnDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicSkReturn.update", logicSkReturnDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicSkReturnDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicSkReturnDO> findListByExample(LogicSkReturnDO logicSkReturnDO) throws DataAccessException {
        List<LogicSkReturnDO> list = getSqlMapClientTemplate().queryForList("LogicSkReturn.findListByDO", logicSkReturnDO);
        return list;
    }

    /**
     * 根据主键获取logicSkReturnDO
     * @param id
     * @return logicSkReturnDO
     */
    public LogicSkReturnDO findLogicSkReturnDOByPrimaryKey(String id) throws DataAccessException {
        LogicSkReturnDO logicSkReturnDO = (LogicSkReturnDO) getSqlMapClientTemplate().queryForObject("LogicSkReturn.findByPrimaryKey", id);
        return logicSkReturnDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    @Override
    public Integer deleteLogicSkReturnDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicSkReturn.deleteByPrimaryKey", id);
        return rows;
    }

    @SuppressWarnings("unchecked")
	@Override
   	public List<LogicSkReturnDO> find(SearchConditions scs)
   			throws DataAccessException {
		List<LogicSkReturnDO> list = getSqlMapClientTemplate().queryForList("LogicSkReturn_ex.find", scs);
   		   return list;
   	}

   	@Override
   	public Integer count(SearchConditions scs) throws DataAccessException {		
   		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicSkReturn_ex.count", scs);
   	      return count;
   	}

	@Override
	public Double findLastedDOByOricode(SearchConditions scs)
			throws DataAccessException {
		Double ythk = (Double) getSqlMapClientTemplate().queryForObject("LogicSkReturn_ex.findLastedDOByOricode", scs);
		return ythk;
	}
}